<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/common/common.jspf" %>
    <script type="text/javascript" src="${ctx}/js/diagnosis/question/add.js">
    </script>
    <script type="text/javascript">
        function addOption() {
            var option = '<div class="form-group">' +
                '                <div class="col-sm-3">' +
                '                    <label class="control-label">选项</label>' +
                '                </div>' +
                '                <div class="col-sm-6">' +
                '                    <input type="text" class="form-control" placeholder="请输入值" name="answers">' +
                '                </div>' +
                '                <div class="col-sm-button">' +
                '                    <button type="button" onclick="delLine(this)" class="btn btn-success btn-s-xs">移除</button>' +
                '                </div>' +
                '            </div>';
            $("#question-panel").append(option);
        }

        function delLine(obj){
            obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
        }

        function selectAnswer() {

            layer.open({
                title: "选项关联",
                type: 2,
                area: ["600px", "90%"],
                content: rootPath + '/app/diagnosis/answerList.shtml'
            });

        }
    </script>
    <style type="text/css">
        .col-sm-3 {
            width: 15%;
            float: left;
            text-align: right;
        }

        .col-sm-9 {
            width: 85%;
            float: left;
            text-align: left;
        }
        .col-sm-6 {
            width: 60%;
            float: left;
            text-align: left;
        }
        .col-sm-button {
            width: 15%;
            float: left;
            text-align: left;
        }
        label[class^="btn btn-default"] {
            margin-top: -4px;
        }
    </style>
</head>
<body>
<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
<form id="form" name="form" class="form-horizontal" method="post" action="${ctx}/app/diagnosis/addEntity.shtml">
    <section class="panel panel-default">
        <div class="panel-body" id="question-panel">
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">题目</label>
                </div>
                <div class="col-sm-6">
                    <input type="text" class="form-control" placeholder="请输入题目" name="diagnosisQuestionFormMap.title">
                </div>
                <div class="col-sm-button">
                    <button type="button" onclick="addOption()" class="btn btn-success btn-s-xs">添加选项</button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">类型</label>
                <div class="col-sm-6">
                    <select id="type" name="diagnosisQuestionFormMap.type" class="form-control m-b"
                            tabindex="-1" style="width: 30%;">
                        <option value="0">无关联</option>
                        <option value="1">有关联</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">关联选项</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" id="reply_answer_names" onclick="selectAnswer()" autocomplete="off" >
                    <input type="hidden" id="reply_answer_ids" name="diagnosisQuestionFormMap.reply_answer_ids">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">选项</label>
                </div>
                <div class="col-sm-6">
                    <input type="text" class="form-control" placeholder="请输入值" name="answers">
                </div>
                <div class="col-sm-button">
                    <button type="button" onclick="delLine(this)" class="btn btn-success btn-s-xs">移除</button>
                </div>
            </div>
        </div>
        <footer class="panel-footer text-right bg-light lter">
            <button type="submit" class="btn btn-success btn-s-xs">提交</button>
        </footer>
    </section>
</form>
</body>
</html>
